package com.bw.common.adapter

import android.graphics.Color
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bw.image.imageLoader

/**
 * 绑定适配器对象
 */
object CommonBindingAdapter {

    @JvmStatic
    @BindingAdapter("imageUrl")
    fun loadUrlImage(imageView:ImageView,url:String){
        if(!url.isNullOrEmpty()){
          imageLoader.loadImg(imageView.context,url,imageView)
        }
    }

    @JvmStatic
    @BindingAdapter("imageCircleUrl")
    fun loadUrlCircleImage(imageView:ImageView,url:String){
        if(!url.isNullOrEmpty()){
            imageLoader.loadImg(imageView.context,url,imageView)
        }
    }
    @JvmStatic
    @BindingAdapter("bgColor")
    fun loadBgColor(imageView: ImageView,colorStr:String){
        if(!colorStr.isNullOrEmpty()){
            imageView.setBackgroundColor(Color.parseColor(colorStr))
        }
    }

}